﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Visuals;
using System.Drawing;

namespace Silvermoon.Controls
{
    /// <summary>
    /// Used with <see cref="T:ListViewBase"/> to separate Items.
    /// </summary>
    public class ItemSeparator : ItemBase
    {
        private RectangleVisual borderLine;

        public ItemSeparator()
            : base()
        {
            borderLine = new RectangleVisual { Color = SystemColors.ActiveBorder };
            Visuals = new Visual[] { borderLine };
            Height = 8;
        }

        protected override void OnSizeChanged()
        {
            if (Height!=8) Height = 8;
            else base.OnSizeChanged();
        }

        protected override void OnLayout()
        {
            if ((InvalidationMask & InvalidationFlag.Size) != 0)
            {
                borderLine.Bounds = Control.ScaledRect(16, Height / 2 - 1, Width - 32, 1);
            }
            base.OnLayout();
        }
    }
}
